import string, os
import datetime

print 'Running MemLatency ...\n'
size = 512
stride = 32
iter = 1000000
trial = 10
now = datetime.datetime.now()
filename = "MemLatency_%s.txt" % now.strftime("%Y-%m-%d-%H-%M")
while size <= 33554432 :
	for i in range(trial) :
#		cmd = "MemLatency " + str(size) + " " + str(stride) + " " + str(iter) + " >> MemLatency.txt" 
		cmd = "MemLatency %d %d %d >> %s" % (size, stride, iter, filename)
		os.popen(cmd)
	size *= 2
	f = open(filename, 'a')
	f.write("\n")
	f.close()

print 'Done! Check results in %s' % filename